#include<iostream>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
const int N = 25, M = 10;
int mp[2010];
int n, m;
int w[N];
int f[2010];
int a[N];
int ans;
bool st[N];
int fun()
{
	memset(f, 0, sizeof(f));
	memset(mp, 0, sizeof(mp));
	int cnt = 0;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (!st[i]) {
			a[++cnt] = w[i];
			sum += w[i];
			//cout << "w[i]==" << w[i] << endl;
		}
	}
	f[0] = 1;
	//cout << "cnt==" << cnt << endl;
	//cout << "sum==" << sum << endl;
	int ans = 0;
	for (int i = 1; i <= cnt; i++) {
		for (int j = sum; j >= 0; j--) {
			if (j >= a[i]) {
				f[j] += f[j - a[i]];
				if (!mp[j] && f[j]) {
					mp[j] = 1;
					ans++;
				}
			}
			/*if (f[j] && !f[j + a[i]]) {
				f[j + a[i]] = 1;
				ans++;
			}*/
		}
	}
	return ans;
}
void dfs(int u, int sum)
{
	//if (sum > m)return;
	if (u == n + 1) {
		if (sum == m) {
			//cout << fun() << endl;
			ans = max(ans, fun());
		}
		return;
	}
	dfs(u + 1, sum);
	st[u] = 1;
	dfs(u + 1, sum + 1);
	st[u] = 0;
	/*for (int i = 1; i <= n; i++) {
		if (!st[i]) {
			st[i] = 1;
			a[u] = w[i];
			dfs(u + 1, sum + 1);
			a[u] = 0;
			st[i] = 0;
		}
	}*/
	
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> w[i];
	dfs(1, 0);
	cout << ans << endl;
	return 0;
}